<?php
/**
 * The header for our theme
 *
 * This is the template that displays all of the <head> section and everything up until <div id="content">
 *
 * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
 *
 * @package Blago
 */

?>
<!doctype html>
<html <?php language_attributes(); ?>>
<head>
	<meta charset="<?php bloginfo( 'charset' ); ?>">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="profile" href="https://gmpg.org/xfn/11">

	<?php wp_head(); ?>
</head>

<body <?php body_class(); ?>>
<?php wp_body_open(); ?>
<div class="conteiner"> 
        <header>
            <div class="menu">
                 <div class="phone menu__phone">     
                    <?php $contacts = carbon_get_theme_option('contacts');?>
                    <?php if($contacts): ?>
                    <div class="phone__number">
                    <?php foreach($contacts as $contact):?>
                    <?php //pr($contact);?>
                    <?php if($contact['show_phone_number'] || $contact['show_phone_number_basic']):?>
                    
                        <div >
                            <span class="phone__name"><?php echo $contact['name']?> : </span>
                            <a href="tel: <?php echo $contact['phone_number']?>">
                                <?php echo $contact['phone_number']?>
                            </a>
                        </div>
                    
                    <?php endif?> 
                    <?php endforeach?>
                    </div>
                    <?php foreach($contacts as $contact):?>
                    <?php if($contact['show_phone_number_basic']):?>
                    <div class="phone__icon">
                        <a href="tel: <?php echo $contact['phone_number']?>">
                            <svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
                                x="0px" y="0px" width="51px" height="51px" viewBox="0 0 512.001 512.001"
                                style="enable-background:new 0 0 512.001 512.001;" xml:space="preserve">
                                <g>
                                    <path
                                        d="M462.491,468.206l-33.938,33.937c-6.062,6.031-23.812,9.844-24.343,9.844c-107.435,0.905-210.869-41.279-286.882-117.31
                                                                                                                                                                                                                                                                                                                                                C41.097,318.46-1.136,214.619,0.036,106.872c0-0.063,3.891-17.312,9.938-23.312l33.937-33.968
                                                                                                                                                                                                                                                                                                                                                c12.453-12.437,36.295-18.062,52.998-12.5l7.156,2.406c16.703,5.562,34.155,23.999,38.78,40.967l17.093,62.717
                                                                                                                                                                                                                                                                                                                                                c4.64,17-1.594,41.186-14.031,53.623l-22.687,22.687c22.25,82.467,86.919,147.121,169.339,169.402l22.687-22.688
                                                                                                                                                                                                                                                                                                                                                c12.438-12.438,36.687-18.656,53.687-14.031l62.718,17.125c16.937,4.594,35.374,22.03,40.968,38.748l2.375,7.156
                                                                                                                                                                                                                                                                                                                                                C480.552,431.926,474.928,455.769,462.491,468.206z M287.996,255.993h31.999c0-35.343-28.655-63.998-63.998-63.998v31.999
                                                                                                                                                                                                                                                                                                                                                C273.636,223.994,287.996,238.368,287.996,255.993z M415.992,255.993c0-88.373-71.623-159.996-159.995-159.996v32
                                                                                                                                                                                                                                                                                                                                                c70.591,0,127.996,57.436,127.996,127.996H415.992z M255.997,0v31.999c123.496,0,223.993,100.497,223.993,223.994h31.999
                                                                                                                                                                                                                                                                                                                                                C511.989,114.622,397.368,0,255.997,0z" />
                                </g>
                                <g>
                                </g>
                                <g>
                                </g>
                                <g>
                                </g>
                                <g>
                                </g>
                                <g>
                                </g>
                                <g>
                                </g>
                                <g>
                                </g>
                                <g>
                                </g>
                                <g>
                                </g>
                                <g>
                                </g>
                                <g>
                                </g>
                                <g>
                                </g>
                                <g>
                                </g>
                                <g>
                                </g>
                                <g>
                                </g>
                            </svg>
                        </a> 
                    </div>
                    <?php endif?>
                    <?php endforeach?>
                    <?php endif?>
                </div>
                <div class="menu__burger">
                    <span></span>
                </div>
                <nav class="menu__nav">
                    <?php dlago_primary_menu();?>
                </nav>
                <div class="menu__icon">
                    <?php 
                        $logo_id = carbon_get_theme_option('blago_header_logo'); 
                        $logo = $logo_id ? wp_get_attachment_image_src( $logo_id , 'full'): '';
                    ?>
                    <?php if(!is_front_page() && !is_home()) :
                        if($logo_id): ?>
                            <a href="<?php echo home_url('/');?>" class="icon"><img src="<?php echo $logo[0]; ?>"
                            alt="Божья Блогодать Паломническая Служба"></a>
                        <?php else :?>
                            <a href="<?php echo home_url('/');?>" class="icon">
                                <?php echo carbon_get_theme_option('blago_hgeader_cite_name');?>
                                <span><?php echo carbon_get_theme_option('blago_hgeader_cite_desc');?></span>
                            </a>
                        <?php endif ; ?>
                    <?php else :
                        if($logo_id): ?>
                            <img src="<?php echo $logo[0]; ?>" alt="Божья Блогодать Паломническая Служба">
                        <?php else :?>
                            <p>
                                <?php echo carbon_get_theme_option('blago_hgeader_cite_name');?>
                                <span><?php echo carbon_get_theme_option('blago_hgeader_cite_desc');?></span>
                            </p>
                        <?php endif ; ?>

                    <?php endif ; ?>
                    
                </div>
            </div>
           <?php 
           if(is_front_page() ) {
                $query = new WP_Query('post_type=travel');
                while ( $query->have_posts() ) :
                $query->the_post();

                if ( carbon_get_the_post_meta('show_sidebar')){
                    $photo = carbon_get_post_meta( get_the_ID(), 'photo');
                    $trips = carbon_get_post_meta( get_the_ID(), 'trips');
                    $img = wp_get_attachment_image_url( $photo , 'full');
            ?>
            <div class="slickSlider">
                <div class="slickSlider__slaid">
                    <a href="<?php the_permalink(); ?>" class="slickSlider__linck">
                        <img src="<?php echo $img?>" alt="<?php the_title(); ?>" class="slickSlider__image">
                    </a>
                    <div class="slickSlider__header">
                        <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                        
                        <div class="slickSlider__date">
                        <?php
                            foreach($trips as $trip){
                            
                            $time  = $trip["data_time_trips"];
                            $number_days =  $trip["number_days_trip"];
                        
                        ?>
                        
                            <div class="slickSlider__dateBox">
                                <p class="days"><?php echo $number_days ; echo "&nbsp;" . number_word($number_days);?> </p>
                                    <div>
                                    <?php foreach ($time as $date) {
                                        $data_departure_trips = new DateTime($date['data_departure_trips']);
                                    ?>
                                     
                                    <h3 class="date"><button class="open_form" type="button" dataDeys="<?php echo $number_days ?>" dataDate="<?php echo $data_departure_trips->format('d.m.Y');?>" dataTitle="<?php the_title(); ?>" dataLinck="<?php the_permalink(); ?>"><?php echo $data_departure_trips->format('d.m.Y');?><br>Заказать</button></h3>
                                    <?php };?>
                                </div>
                            
                            </div>
                            <?php };?>
                        </div>
                        
                    </div>
                </div>
            
            <?php } endwhile; wp_reset_postdata()?>
            </div>
            <?php }?>
            <?php if(is_single()){?>
            <div class="header__product">
                <div class="slickSlider__product">
                    <?php
                        $trips = carbon_get_post_meta( get_the_ID(), 'trips');
                        $photo = carbon_get_post_meta( get_the_ID(), 'photo');
                        $img = wp_get_attachment_image_url( $photo , 'full');
                    ?>
                    <div class="slickSlider__slaid">
                        <a href="" class="slickSlider__linck">
                            <img src="<?php echo $img ?>" alt="" class="slickSlider__image">
                        </a>
                    </div>
                    <?php
                    foreach ($trips as $trip) {
                    $event = $trip['event'];
                        foreach ($event as $events) {
                            $thumbnail_url = wp_get_attachment_image_url( $events['foto_event'], 'large' ); 
                    ?>
                    <div class="slickSlider__slaid">
                        <a href="" class="slickSlider__linck">
                            <img src="<?php echo $thumbnail_url ?>" alt="" class="slickSlider__image">
                        </a>
                    </div>
                        <?php } ?> 
                    <?php } ?> 
                </div>
                <div class="headerData">
                    <h1><?php the_title();?></h1>
                    <div class="headerData__price">
                        <?php foreach ($trips as $trip) {
                            $number_days =  $trip["number_days_trip"];
                        ?>
                        <div class="headerDate__block">
                            <p class="days"><?php echo $number_days ; echo "&nbsp;" . number_word($number_days);?> </p>
                            <?php foreach ($trip["data_time_trips"] as $data_time_trips) {
                                $data_departure_trips = new DateTime($data_time_trips["data_departure_trips"]);
                            ?>
                            <!-- <p class=""></p> -->
                            <button class="open_form" type="button" dataDeys="<?php echo $number_days ?>" dataDate="<?php echo $data_departure_trips->format('d.m.Y');?>" dataTitle="<?php the_title(); ?>" dataLinck="<?php the_permalink(); ?>"><?php echo $data_departure_trips->format('d.m.Y');?><br>Заказать</button>
                            <?php };?>
                            <p class="headerData__priced"><?php echo $trip['price_place'] ?>&nbsp;&#8381;</p>
                            
                        </div>
                            <?php };?>
                           <!-- <button class="button__product"type="button" dataTitle="<?php the_title(); ?>" dataLinck="<?php the_permalink(); ?>"></button> -->
                    </div>
                    
                </div>
            </div>
            <?php }; wp_reset_postdata(); ?>
        </header>